package testTransfoUML2Java;


import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import uml2Java.JavaChargeur;
import uml2Java.TransformInheritance;
import uml2Java.TransformPackagesAndTypes;
import uml2Java.UMLChargeur;
import astjava.ClassDeclaration;
import astjava.InterfaceDeclaration;
import astjava.JavaFactory;

public class TestTransformInheritance {
	
	private static org.eclipse.uml2.uml.Package _umlPackage;
	
	private static astjava.Model _javaModel;
	
	private static TransformPackagesAndTypes _transformerTypes;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		_javaModel = JavaFactory.eINSTANCE.createModel();
		UMLChargeur chargeur = new UMLChargeur("modele_de_test/testInheritance.uml");
		_umlPackage = chargeur.loadUMLPackage();
		
		_transformerTypes = new TransformPackagesAndTypes(_umlPackage, _javaModel);
		_transformerTypes.doTransformPackagesAndTypes();
		TransformInheritance transformerInheritance = new TransformInheritance(_transformerTypes);
		transformerInheritance.doTransformInheritance();
	}
	
	@Test
	public void TestTransformInterface() {
		InterfaceDeclaration javaInterface = (InterfaceDeclaration) _transformerTypes.get_symbolMap().get("Interface1");
		assertNotNull(javaInterface.getSuperInterfaces());
		assertTrue(javaInterface.getSuperInterfaces().size()==2);
	}
	
	@Test
	public void TestTransformClass() {
		ClassDeclaration javaClass = (ClassDeclaration) _transformerTypes.get_symbolMap().get("Classe");
		assertNotNull(javaClass.getSuperClass());
		assertTrue(javaClass.getSuperInterfaces().size()==2);
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		JavaChargeur chargeur = new JavaChargeur("modele_de_test/testInheritance.astjava");
		chargeur.save(_javaModel);
	}

}
